﻿using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using BCCommon.OAEnums;
using BCEntity.OA.Attendance.AttendanceGroup;
using BCEntity.OA.Attendance.AttendanceLocation;
using BCEntity.OA.Attendance.AttendancePlan;
using BCEntity.OA.Attendance.AttendanceWiFi;

namespace BCData.OA.Attendance.AttendanceGroup
{
    public interface IAttendanceGroupData
    {
        /// <summary>
        /// 分页获取考勤组信息列表
        /// </summary>
        /// <param name="pageIndex">起始页</param>
        /// <param name="pageSize">页数量</param>
        /// <param name="ascending">排序</param>
        /// <param name="groupName">考勤组名称</param>
        /// <param name="type">考勤类型</param>
        /// <param name="checkInMode">打卡方式</param>
        /// <returns></returns>
        Task<(IEnumerable<AttendanceGroupEntity>, int)> GetAsync(long adminId, int pageIndex, int pageSize, bool ascending, string groupName, AttendanceType? type, CheckInMode? checkInMode);

        /// <summary>
        /// 获取考勤组信息
        /// </summary>
        /// <param name="groupId">班次Id</param>
        /// <returns></returns>
        Task<AttendanceGroupEntity> GetEntityAsync(long groupId);

        /// <summary>
        /// 获取考勤组信息
        /// </summary>
        /// <param name="departmentId">部门Id</param>
        /// <param name="companyId">公司Id</param>
        /// <returns></returns>
        Task<AttendanceGroupEntity> GetEntityByDepartmentIdAndCompanyIdAsync(int departmentId, int companyId);

        /// <summary>
        /// 获取考勤组Id
        /// </summary>
        /// <param name="departmentId">部门Id</param>
        /// <param name="companyId">公司Id</param>
        /// <returns></returns>
        Task<long> GetGroupIdByDepartmentIdAndCompanyIdAsync(int departmentId, int companyId);

        #region 新增操作

        /// <summary>
        /// 新创建一个考勤组信息
        /// </summary>
        /// <param name="entity">考勤组</param>
        /// <returns></returns>
        Task<AttendanceGroupEntity> InsertAsync(AttendanceGroupEntity entity, List<AttendanceLocationEntity> locationEntities, List<AttendanceWiFiEntity> wiFiEntities, List<AttendanceGroupFixedEntity> fixedEntities = null, List<AttendancePlanEntity> planEntities = null);

        #endregion

        /// <summary>
        /// 校验考勤组息存在不
        /// </summary>
        /// <param name="groupId">考勤组Id</param>
        /// <returns></returns>
        Task<bool> CheckIsExist(long groupId);

        /// <summary>
        /// 校验部门考勤组息存在不
        /// </summary>
        /// <param name="departmentId">部门Id</param>
        /// <param name="companyId">公司Id</param>
        /// <returns></returns>
        Task<bool> CheckDepartmentIsExist(int departmentId, int companyId);

        /// <summary>
        /// 删除考勤组
        /// </summary>
        /// <param name="groupId">考勤组Id</param>
        /// <param name="adminName">管理员信息</param>
        /// <returns></returns>
        Task<int> DeleteAsync(long groupId, string adminName = null);

        /// <summary>
        /// 修改考勤组信息
        /// </summary>
        /// <param name="entity">考勤组</param>
        /// <returns></returns>
        Task<AttendanceGroupEntity> UpdateAsync(AttendanceGroupEntity entity, List<AttendanceLocationEntity> locationEntities, List<AttendanceWiFiEntity> wiFiEntities, List<AttendanceGroupFixedEntity> fixedEntities = null, List<AttendancePlanEntity> planEntities = null);

        /// <summary>
        /// 更新指定的考勤组有效日期
        /// </summary>
        /// <param name="groupId">考勤组Id</param>
        /// <param name="dateTime">日期</param>
        /// <returns></returns>
        Task<AttendanceGroupEntity> UpdateEffectiveDateAsync(long groupId, DateTime dateTime);

        #region 可扩展

        /// <summary>
        /// 根据考勤组Id获取固定设置信息列表
        /// </summary>
        /// <param name="groupId">考勤组Id</param>
        /// <returns></returns>
        Task<IEnumerable<AttendanceGroupFixedViewEntity>> GetGroupFixedByGroupId(long groupId);

        /// <summary>
        /// 根据考勤组Id获取排班信息列表
        /// </summary>
        /// <param name="groupId">考勤组Id</param>
        /// <returns></returns>
        Task<IEnumerable<AttendancePlanViewEntity>> GettGroupPlanByGroupId(long groupId);


        Task<AttendanceGroupEntity> GetFirstNoneAttendanceGroup();

        #endregion
    }
}
